package com.will.txj.aj.security.config.handle;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.oauth2.provider.token.TokenEnhancer;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
import org.springframework.security.oauth2.provider.token.store.JwtTokenStore;

/**
 * @author: wen-yi;
 * @date: 2021/12/5 23:24;
 * @Description: jwt核心配置
 */
@Configuration
public class JwtTokenConfig {
    @Bean
    public TokenStore jwtTokenStore(){
        return new JwtTokenStore(jwtAccessTokenConverter());
    }

    @Bean
    public JwtAccessTokenConverter jwtAccessTokenConverter(){
        //jwt 与 access 之间做转换
        JwtAccessTokenConverter jwtAccessTokenConverter = new JwtAccessTokenConverter();
        //设置密钥
        jwtAccessTokenConverter.setSigningKey("wy@aj");
        return jwtAccessTokenConverter;
    }

    //@Bean
    public TokenEnhancer tokenEnhancer(){
        return new MyTokenEnhancer();
    }
}
